<script type="text/javascript" src="/javaScript/edit_colors.js"></script>
<?php
/* @var $this ColorsController */
//echo '<pre>'; print_r($colors); exit;
$this->breadcrumbs=array(
	'Colors',
);
?>

<div class="top">
    <span class="top-left"><h1>Редактор цветов</h1></span>
    <span class="top-right">
        <?php $form=$this->beginWidget('CActiveForm', array(
            'action'=>$this->createUrl('index', array(
                'sort'=>$sort->orderBy,
            )),
            'method'=>'get',
            'enableAjaxValidation'=>false,
        )); ?>
        Показывать на странице:
        <?php echo CHtml::dropDownList('pageSize', $pages->pageSize, array(
            10=>10,
            15=>15,
            20=>20,
            30=>30,
            50=>50,
            $pages->itemCount=>'all',
        ), array(
            'id'=>'page-size',
        )); ?>
        <?php $this->endWidget(); ?>
    </span>
</div>
<div class="form">
<?php echo CHtml::beginForm(); ?>
    <table>
        <tr>
            <th>
                <a href="javascript:void(0);" id="deleteAll">Удалить</a>
            </th>
            <th><?php echo $sort->link('id') ?></th>
            <th><?php echo $sort->link('color') ?></th>
            <th><?php echo $sort->link('r') ?></th>
            <th><?php echo $sort->link('g') ?></th>
            <th><?php echo $sort->link('b') ?></th>
            <th>Цвет</th>
        </tr>

        <?php foreach($colors as $i=>$color): ?>
        <tr>
            <td class="hidden"><?php echo CHtml::activeTextField($color, "[$i]id"); ?></td>
            <td><?php echo CHtml::activeCheckBox($color, "[$i]delete"); ?></td>
            <td><?php echo $color->id; ?></td>
            <td><?php echo CHtml::activeTextField($color, "[$i]color"); ?></td>
            <td><?php echo CHtml::activeTextField($color, "[$i]r"); ?></td>
            <td><?php echo CHtml::activeTextField($color, "[$i]g"); ?></td>
            <td><?php echo CHtml::activeTextField($color, "[$i]b"); ?></td>
            <td id="<?php echo 'Colors_'.$i.'_color_example'; ?>" class="color example" style="background-color:rgb(<?php echo $color->r; ?>, <?php echo $color->g; ?>, <?php echo $color->b; ?>);"></td>
        </tr>
        <?php endforeach; ?>

        <tr id="newRow"></tr>
    </table>
    <?php echo CHtml::submitButton('Сохранить', array(
        'name'=>'saveColors',
    )); ?>
    <?php echo CHtml::submitButton('Добавить цвет', array(
        'name'=>'addColor',
    )); ?>
<?php echo CHtml::endForm(); ?>
    <?php $this->widget('CLinkPager', array(
        'pages' => $pages,
        'firstPageLabel'=>'&lt;&lt;',
        'prevPageLabel'=>'&lt;',
        'nextPageLabel'=>'&gt;',
        'lastPageLabel'=>'&gt;&gt;',
        'cssFile'=>false,
        'maxButtonCount'=>7,
    )) ?>
</div>